import 'dart:js' as js;

class GanZhi {
  late dynamic ptr;
  late bool needDispose;

  GanZhi({dynamic ptr, this.needDispose = true, int tg = 0, int dz = 0}) {
    if (ptr != null) {
      this.ptr = ptr;
    } else {
      this.ptr = js.context.callMethod("_GanZhi_new");
    }
    js.context.callMethod("_GanZhi_setTianGan", [ptr, tg]);
    js.context.callMethod("_GanZhi_setDiZhi", [ptr, dz]);
  }

  int get tianGan {
    return js.context.callMethod("_GanZhi_getTianGan", [ptr]);
  }

  int get diZhi {
    return js.context.callMethod("_GanZhi_getDiZhi", [ptr]);
  }

  dispose() {
    if (needDispose) {
      js.context.callMethod("_SiZhu_free", [ptr]);
    }
  }
}
